from docclass import getwords
from docclass import classifier
from docclass import naivebayes
from docclass import fisherclassifier
import os.path

def train(training_sets, classifiers):
    for t_set in training_sets.keys():
        fn = training_sets[t_set]
        infile = open(fn, "r")
        while infile:
            line = infile.readline()
            print line + ": " + t_set
            if not line:
                break
            for cl in classifiers.values():
                cl.train(line, t_set)

training_sets = {"news":"news.txt", "weather":"weather.txt"}
fisher_cl = fisherclassifier(getwords)
naive_cl = naivebayes(getwords)

fisher_cl.setdb("fisher.db")
naive_cl.setdb("naive.db")

cls = {"fisher":fisher_cl, "naive":naive_cl}

train(training_sets, cls)

